package com.j2eefast.flowable.erp.service;


import com.j2eefast.flowable.erp.entity.bpmErpPersonPayEntity;
import com.j2eefast.flowable.erp.mapper.bpmErpPersonPayMapper;
import com.j2eefast.common.core.mutidatasource.annotaion.DataSource;
import com.j2eefast.common.core.page.Query;
import com.j2eefast.common.core.utils.PageUtil;
import com.j2eefast.common.core.utils.ToolUtil;
import com.j2eefast.framework.utils.Constant;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import javax.annotation.Resource;
import org.springframework.transaction.annotation.Transactional;
import java.util.Map;
import java.util.Arrays;
/**
 *
 * ERP付款信息Service接口
 * @author: yhli
 * @date 2020-07-16 10:07
 */
@Service
public class bpmErpPersonPayService extends ServiceImpl<bpmErpPersonPayMapper,bpmErpPersonPayEntity> {

	@Resource
	private bpmErpPersonPayMapper bpmErpPersonPayMapper;

	/**
	 * mybaitis-plus 页面分页查询
     */
    @DataSource(name="FLOWABLE")
	public PageUtil findPage(Map<String, Object> params) {
        QueryWrapper<bpmErpPersonPayEntity> queryWrapper = new QueryWrapper<bpmErpPersonPayEntity>();
                 String applyUsername = (String) params.get("applyUsername");
        queryWrapper.like(ToolUtil.isNotEmpty(applyUsername), "apply_username", applyUsername);
             String beneficiaryUsername = (String) params.get("beneficiaryUsername");
        queryWrapper.like(ToolUtil.isNotEmpty(beneficiaryUsername), "beneficiary_username", beneficiaryUsername);
                      String payConfirmpay = (String) params.get("payConfirmpay");
         queryWrapper.eq(ToolUtil.isNotEmpty(payConfirmpay), "pay_confirmpay", payConfirmpay);
          String payPaymentdate = (String) params.get("payPaymentdate");
         queryWrapper.eq(ToolUtil.isNotEmpty(payPaymentdate), "pay_paymentdate", payPaymentdate);
          String payPreferencePaymethod = (String) params.get("payPreferencePaymethod");
         queryWrapper.eq(ToolUtil.isNotEmpty(payPreferencePaymethod), "pay_preference_paymethod", payPreferencePaymethod);
                String payProof = (String) params.get("payProof");
         queryWrapper.eq(ToolUtil.isNotEmpty(payProof), "pay_proof", payProof);
          String payRecipientName = (String) params.get("payRecipientName");
        queryWrapper.like(ToolUtil.isNotEmpty(payRecipientName), "pay_recipient_name", payRecipientName);
          String payRecipientAddress = (String) params.get("payRecipientAddress");
         queryWrapper.eq(ToolUtil.isNotEmpty(payRecipientAddress), "pay_recipient_address", payRecipientAddress);
          String payRecipientPhone = (String) params.get("payRecipientPhone");
         queryWrapper.eq(ToolUtil.isNotEmpty(payRecipientPhone), "pay_recipient_phone", payRecipientPhone);
                      String payBankName = (String) params.get("payBankName");
        queryWrapper.like(ToolUtil.isNotEmpty(payBankName), "pay_bank_name", payBankName);
                   String cashierDate = (String) params.get("cashierDate");
         queryWrapper.eq(ToolUtil.isNotEmpty(cashierDate), "cashier_date", cashierDate);
                   String cashierSubmitTime = (String) params.get("cashierSubmitTime");
         queryWrapper.eq(ToolUtil.isNotEmpty(cashierSubmitTime), "cashier_submit_time", cashierSubmitTime);
                    		Page<bpmErpPersonPayEntity> page = bpmErpPersonPayMapper.selectPage(new Query<bpmErpPersonPayEntity>(params).getPage(), queryWrapper);
		return new PageUtil(page);
    }

    /**
     * 自定义分页查询，含关联实体对像
     */
    @DataSource(name="FLOWABLE")
	public PageUtil findPage(Map<String, Object> params,bpmErpPersonPayEntity bpmErpPersonPayEntity) {
		Page<bpmErpPersonPayEntity> page = bpmErpPersonPayMapper.findPage(new Query<bpmErpPersonPayEntity>(params).getPage(), bpmErpPersonPayEntity,(String) params.get(Constant.SQL_FILTER))  ;
		return new PageUtil(page);
	}
	/**
     * 批量删除
     */
    @DataSource(name="FLOWABLE")
	@Transactional(rollbackFor = Exception.class)
	public boolean deletebpmErpPersonPayByIds(String[] ids) {
		return removeByIds(Arrays.asList(ids));
	}

	/**
     * 单个删除
     */
    @DataSource(name="FLOWABLE")
	public boolean deletebpmErpPersonPayById(String id) {
		return removeById(id);
	}

	/**
     * 保存
     */
    @DataSource(name="FLOWABLE")
	public boolean savebpmErpPersonPay(bpmErpPersonPayEntity bpmErpPersonPay){
        return save(bpmErpPersonPay);
    }

	/**
     * 修改根居ID
     */
    @DataSource(name="FLOWABLE")
	public boolean updatebpmErpPersonPayById(bpmErpPersonPayEntity bpmErpPersonPay) {
		return updateById(bpmErpPersonPay);
	}

	/**
     * 根居ID获取对象
     */
    @DataSource(name="FLOWABLE")
	public bpmErpPersonPayEntity getbpmErpPersonPayById(String id){
		return getById(id);
	}
}
